<script type="text/javascript">
    $(document).ready(function () {
        $('#is_presell_1').click(function () {

            $('#is_presell').show();
            $('#is_presell2').hide();
        });
        $('#is_presell_0').click(function () {
            $('#is_presell').hide();
            $('#is_presell2').show();
        });
    });
</script>
<div class="admin">
    <form method="post" name="myform" id="myform" action="">
        <div class="tab panel dux-tab admin-panel">
            <div class="panel-head">
                <div class="tab-head">
                    <strong>添加商品</strong>
                    <ul class="tab-nav">
                        <li class="active"><a href="#tab-1">基本信息</a></li>
                    </ul>
                </div>
            </div>
            <div class="tab-body">
                <div class="tab-panel active" id="tab-1">
                    <table class="table table-hover">
                        <tr>
                            <td width='160px'><span class="c-red">*</span>商品分类：</td>
                            <td id="recommend_gcategory">
                                <input type="hidden" id="cate_id" name="class3" value="0" class="mls_id" />
                                <input type="hidden" id="cate_name" name="classname" value="" class="mls_names" />
                                <select class="inputL input_small" datatype="*">
                                    <option value="">-请选择-</option>
                                    <foreach item="v" name="category">
                                        <option value="{$v['cat_id']}">{$v['cat_name']}</option>
                                    </foreach>
                                </select>
                            </td>
                            <td width='*'></td>
                        </tr>
                        <tr>
                            <td width='160px'><span class="c-red">*</span>商品名称：</td>
                            <td width='*'>
                                <input type="text" class="input input_big" value="" datatype="*" placeholder="" id="" name="goods_title" />
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td width='*'></td>
                        </tr>
                        <tr>
                            <td width='160px'><span class="c-red">*</span>商品货号：</td>
                            <td width='*'>
                                <input type="text" class="input input_big" value="<?php echo "TDD" . session('store_id') . time(); ?>" datatype="*" placeholder="" id="" name="goods_number" />
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td width='*'></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>轮播图片：</td>
                            <td>
                                <div class="goodspic-uplaod">
                                    <!-- 图片上传按钮 -->
                                    <input class="fileupload" type="file" name="image" data-name="goods_images[]" data-num="5" />
                                    <!-- 图片展示模块 -->
                                    <div class="files"></div>
                                    <div style="clear:both;"></div>
                                    <!-- 图片上传进度条模块 -->
                                    <div class="up_progress"><div class="progress-bar"></div></div>
                                </div>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>进货价：</td>
                            <td>
                                <input name="goods_stockprice" class="inputL input_smallL" datatype="*" type="text" value="0" /><em class="add-on">元</em>
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>销售价：</td>
                            <td>
                                <input name="goods_price" class="inputL input_smallL" datatype="*" type="text"  value="0" /><em class="add-on">元</em>
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>市场价：</td>
                            <td>
                                <input name="goods_markprice" class="inputL input_smallL" datatype="*" type="text" value="0" /><em class="add-on">元</em>
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                        <script type="text/javascript">
                            //自动生成市场价
                            $("input[name='goods_price']").blur(function () {
                                $("input[name='goods_markprice']").val(Number($(this).val()) * 1.2);
                            })
                        </script>
                        <tr>
                            <td><span class="c-red">*</span>库存：</td>
                            <td>
                                <input name="goods_stock" class="inputL input_smallL" datatype="*" type="text" value="999" /><em class="add-on">件</em>
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>所属店铺：</td>
                            <td>
                                <input name="goods_store" class="inputL input_big" type="text" value="" />
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td><span class="c-red">*</span>简短描述：</td>
                            <td>
                                <textarea class="input input_big" name="goods_buytitle" id="voucher_desc" cols="62" rows="3"></textarea>
                                <div class="label Validform_checktip"></div>
                            </td>
                            <td></td>
                        </tr>
                            <tr>
                                <td><span class="c-red">*</span>店铺分类：</td>
                                <td>
                                    <select name="stc_id" class="inputL input_small">
                                        <option value="0">请选择</option>
                                        <foreach item="v" name="storeClass">
                                            <option value="{$v['stc_id']}">{$v['stc_name']}</option>
                                        </foreach>
                                    </select>
                                    <div class="label Validform_checktip"></div>
                                </td>
                                <td></td>
                            </tr>
                    </table>

                    <table class="table table-hover">
                        <tr>
                            <td width='160px'><span class="c-red">*</span>商品详情：</td>
                            <td>
                                <script type="text/javascript" charset="utf-8" src="/Public/ueditor1_4_3/ueditor.config.js"></script>
                                <script type="text/javascript" charset="utf-8" src="/Public/ueditor1_4_3/ueditor.all.min.js"></script>
                                <script type="text/javascript" charset="utf-8" src="/Public/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
                                <textarea id="editor" type="text/plain" style="width:72%;height:350px;" name="goods_content" ></textarea>
                                <script>
                            var ue = UE.getEditor('editor', {
                                autoFloatEnabled: false,
                                elementPathEnabled: false
                            });
                            UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
                            UE.Editor.prototype.getActionUrl = function (action) {
                                if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
                                    return '{:STORE_URL}/Store/ueditor';
                                } else {
                                    return this._bkGetActionUrl.call(this, action);
                                }
                            }
                                </script>
                            </td>
                        </tr>
                    </table>

                    <table class="table table-hover">
                        <tr>
                            <td><span class="c-red">*</span>参数：</td>
                            <td>
                                <div class="attr">
                                </div>
                                <span id="addattr" class="button bg-blue"><i class="icon-plus"></i> 添加参数</span>
                                <span id="reduceattr" class="button bg-blue"><i class="icon-minus"></i> 减少参数</span>
                            </td>
                            <td></td>
                        </tr>
                    </table>

                    <table class="table table-hover">
                        <tr>
                            <td><span class="c-red">*</span>规格：</td>
                            <td>
                                <div class="guige_show">
                                    <div class="guige">
                                        <div>
                                            <label>规格名称</label>
                                            <input id="class_name" type="text" name="sex" placeholder="请输入规格名称" />
                                        </div>
                                        <div>
                                            <label>规格值</label>
                                            <input id="class_data" type="text" name="sex" class="guige_date" placeholder="(多规格请使用逗号隔开)例：红色,白色" />
                                            <select class="guige_ji">
                                                <option value='0'>添加至1级规格</option>
                                                <option value='1'>添加至2级规格</option>
                                            </select>
                                            <input type="button" class="guige_tijiao" value="添加" />
                                        </div>
                                    </div>
                                    <div class="guige_show_tian">
                                    </div>
                                </div>
								<script>
									var date_linshi={};
									//var date_linshi={'floor[class0:00_class1:00]': "242", 'price[class0:00_class1:00]': "24", 'fprice[class0:00_class1:00]': "28.80", 'stock[class0:00_class1:00]': "242", 'floor[class0:00_class1:10]': "242"}
								</script>
                                <div class="guige_xiugai">
                                    <div class="">
                                        <table class="guige_xiugai_main_table" border="0" cellspacing="0" cellpadding="0">
                                            <tbody>

                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </td>
                            <td></td>
                        </tr>
                    </table>

                    <table class="table table-hover">
                        <tr>
                            <td width='160px'><span class="c-red">*</span>运费类型：</td>
                            <td width='*'>
                                <div class="field">
                                    <div class="button-group button-group-small radio">
                                        <label class="button active"><input name="vr_status" id="is_presell_1" value="1" checked="checked" type="radio"><span class="icon icon-check"></span>运费模版</label>
                                        <label class="button"><input name="vr_status" id="is_presell_0" value="0" type="radio"><span class="icon icon-times"></span>免运费</label>
                                    </div>
                                </div>
                            </td>
                            <td width='*'></td>
                        </tr>
                    </table>

                    <table class="table table-hover" id="is_presell">
                            <tr>
                                <td width='160px'><span class="c-red">*</span>选择模版：</td>
                                <td>
                                    <select name="transport_id" class="inputL input_small">
                                        <option value="0">请选择</option>
                                        <foreach item="v" name="transport">
                                            <option value="{$v['id']}">{$v['title']}</option>
                                        </foreach>
                                    </select>
                                    <div class="label Validform_checktip"></div>
                                </td>
                                <td></td>
                            </tr>
                    </table>
                </div>
            </div>
            <div class="panel-foot text-center">
                <div class="form-button">
                    <input class="button bg-main" type="submit" value="确认保存">
                    <button class="button bg" type="reset">取消</button>
                </div>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="__JS__/jquery.uploads.js"></script>
<script type="text/javascript" src="__JS__/store/addclass.js"></script>
<script type="text/javascript">
        $("#myform").Validform({
            tiptype: 3,
            showAllError: true,
        });

        $('#myform').layer({
        });
        gcategoryInit("recommend_gcategory");

        var htmla = '<div class="ncsc-mansong-rule"><span >商品参数&nbsp;<input name="para_name[]" class="inputL input_smallL" type="text">，</span><span>参数值&nbsp;<input name="para_value[]" class="inputL input_smallL" type="text"></span></div>';
        $("#addattr").click(function () {
            var num = $(".ncsc-mansong-rule").length;
            if (num <= 11) {
                $(".attr").append(htmla);
            } else {
                layer.msg('参数最多添加十二个！！！');
            }
        });
        //减少商品属性  规格
        $("#reduceattr").click(function () {
            var num = $(".ncsc-mansong-rule").length;
            if (num != 0) {
                $(".attr div:last-child").remove();
            }
        });
</script>